﻿using System;
using System.Text;
using EzDesk.Apps.Model.ProjectModule;
using EzDesk.Core.Interface;
using EzDesk.Core.ServiceImpl.Services;

namespace EzDesk.Apps.ServiceImpl.ProjectModule.History
{
    public abstract class HistoryRecorderBase
    {
        public abstract ProjectHistory ProjectHistory{get;}
        protected ICoreAppService EzApiClient
        {
            get { return new CoreAppService(); }
        }

        protected string GetMuiltipleLineContent(StringBuilder sb)
        {
            sb.Replace(Environment.NewLine, "<br />").Replace("<br />", "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

            var result = sb.ToString();
            // 去掉最后多余的换行
            if (result.EndsWith("<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"))
            {
                result = result.Remove(sb.Length - "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".Length, "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".Length);
            }
            return result;
        }
    }
}